<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd">

	<!-- Define the controllers using annotations -->
	<bean
		class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
	<bean
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
	<context:component-scan base-package="de.fhd.pms.ctrl" />


	<!-- ******************* -->
	<!-- DB and Hibernate -->
	<!-- ******************* -->

	<bean class="de.fhd.pms.Startup" id="init" init-method="initDB">
		<property name="driverClass" value="com.mysql.jdbc.Driver" />
		<property name="user" value="root" />
		<property name="password" value="" />
		<property name="defaultDBurl" value="jdbc:mysql://localhost:3306/mysql" />
		<property name="newDB" value="autovermietung" />
	</bean>

	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
		destroy-method="close" depends-on="init">
		<property name="driverClass" value="com.mysql.jdbc.Driver" />
		<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/autovermietung" />
		<property name="user" value="root" />
		<property name="password" value="" />
		<property name="minPoolSize" value="2" />
		<property name="maxPoolSize" value="4" />
	</bean>

	<bean id="hibernateSessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<!-- Es wird die obere Instanz eingeschleust -->
		<property name="dataSource" ref="dataSource" />
		<property name="annotatedClasses">
			<list>
				<value>de.fhd.pms.model.Auto</value>
				<value>de.fhd.pms.model.Fahrt</value>
				<value>de.fhd.pms.model.Kunde</value>
				<value>de.fhd.pms.model.Station</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
	</bean>

	<!-- ******************* -->
	<!-- Data Access Objects -->
	<!-- ******************* -->

	<bean id="kundeDao" class="de.fhd.pms.dao.KundeDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
	</bean>
	<bean id="stationDao" class="de.fhd.pms.dao.StationDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
	</bean>
	<bean id="fahrtDao" class="de.fhd.pms.dao.FahrtDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
	</bean>
	<bean id="autoDao" class="de.fhd.pms.dao.AutoDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
<!-- 	<property name="fahrtDao" ref="fahrtDao" /> -->
	</bean>

	<!-- ******************* -->
	<!-- Controllers -->
	<!-- ******************* -->

	<bean id="kundeController" class="de.fhd.pms.ctrl.KundeController">
		<property name="kundeDao" ref="kundeDao" />
	</bean>
	<bean id="stationController" class="de.fhd.pms.ctrl.StationController">
		<property name="stationDao" ref="stationDao" />
	</bean>
	<bean id="autoController" class="de.fhd.pms.ctrl.AutoController">
		<property name="autoDao" ref="autoDao" />
		<property name="stationDao" ref="stationDao" />
		<property name="kundeDao" ref="kundeDao" />
	</bean>
	<bean id="fahrtController" class="de.fhd.pms.ctrl.FahrtController">
		<property name="fahrtDao" ref="fahrtDao" />
		<property name="autoDao" ref="autoDao" />
		<property name="kundeDao" ref="kundeDao" />
		<property name="stationDao" ref="stationDao" />
		
	</bean>

	<!-- ******************* -->
	<!-- Views -->
	<!-- ******************* -->

	<!-- Als Präfix den Name z.B. home von der Controller Datei -->
	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/view/" />
		<property name="suffix" value=".jsp" />
	</bean>

</beans>